<?php

require_once('Classes/Datasources/Filters/Filter_TableEndsWith.php');


class Test_Filter_TableEndsWith extends UnitTestCase {
    
    function test_ShouldIncludeTableReturnsTrueIfThePassedStringEndsWithTheStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableEndsWith( 'True' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
    }

    function test_ShouldIncludeTableReturnsTrueIfThePassedStringIsExactlyTheSameAsTheStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableEndsWith( 'ThisIsTrue' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
    }

    function test_ShouldIncludeTableReturnsTrueIfThePassedStringEndsWithTheStringGivenInTheConstructorEvenIfTheCaseDoesNotMatch() {
    	$oFilter = new Filter_TableEndsWith( 'True' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'THISISTRUE' ) );

    	$oFilter = new Filter_TableEndsWith( 'TRUE' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'thisistrue' ) );
    }
    function test_ShouldIncludeTableReturnsFalseIfThePassedStringDoesNotEndWithTheStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableEndsWith( 'That' );
        $this->assertFalse(  $oFilter->ShouldIncludeTable( 'ThisIsNotTrue' ) );
    }

    function test_ShouldIncludeTableAlwaysReturnsTrueIfTheStringGivenInTheConstructorIsEmpty() {
    	$oFilter = new Filter_TableEndsWith( '' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'THISISTRUE' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( '' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( '678432y7r87yfv' ) );
    }
    
    function test_ShouldIncludeTableReturnsFalseIfTheStringPassedIsShorterThanThatGivenInTheConstructor() {
    	$oFilter = new Filter_TableEndsWith( 'SomeText' );
        $this->assertFalse( $oFilter->ShouldIncludeTable( 'Text' ) );
        $this->assertFalse( $oFilter->ShouldIncludeTable( 'omeText' ) );
    }

    function test_ShouldIncludeTableIgnoresWhitespaceAtTheEndOfBothStringsBeingCompared() {
    	$oFilter = new Filter_TableEndsWith( 'SomeText	  	' );
        $this->assertTrue( $oFilter->ShouldIncludeTable( 'ThingSomeText' ) );
    	$oFilter = new Filter_TableEndsWith( 'SomeText' );
        $this->assertTrue( $oFilter->ShouldIncludeTable( 'ThingSomeText 	 ' ) );
    }
}

?>
